package com.chidopi.market.aa;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import com.chidopi.cdf.tag.ITagDao;
import com.chidopi.market.aa.actions.AccountAction;
import com.chidopi.market.aa.actions.LoginAction;
import com.chidopi.market.aa.actions.MainAction;
import com.chidopi.market.aa.actions.PasswordAction;
import com.chidopi.market.aa.actions.RoleAction;
import com.chidopi.market.aa.dao.impl.TagDaoImpl;


@Component
//@Import(RootConfig.class) // Suggest Action class don't import DB class
public class AppConfig {
	private static Logger logger = LoggerFactory.getLogger(AppConfig.class);
	@Bean(name="/login")
	public LoginAction loginAction() {
		logger.debug("call login of LoginAction");
		return new LoginAction();
	}

	@Bean(name="/echo")
	public LoginAction echo() {
		logger.debug("call echo of LoginAction");
		return new LoginAction();
	}

	@Bean(name="/main")
	public MainAction main() {
		logger.debug("call MainAction");
		return new MainAction();
	}

	@Bean(name="tagDao")
	public ITagDao iTagDao() {
		logger.debug("call TagDaoImpl");
		return new TagDaoImpl();
	}

	/**
	 * Account Maintain
	 */
	@Bean(name={"/account",
				"/ajaxAccountQuery",
				"/insertAccount",
				"/updateAccount",
				"/deleteAccount",
				"/saveAccount",
				"/ajaxValidateAccount"})
	public AccountAction account() {
		logger.debug("call AccountAction");
		return new AccountAction("/account");
	}
	
	/**
	 * Account Password Maintain
	 */
	@Bean(name={"/pwd",
			    "/changePwd"})
	public PasswordAction passwordAction() {
		logger.debug("call passwordAction");
		return new PasswordAction("/pwd");
	}

	/**
	 * Role Maintain
	 */
	@Bean(name={"/role",
				"/ajaxRoleQuery",
				"/ajaxRoleQueryFunctionItem",	// used by roleEdit
				"/insertRole",
				"/updateRole",
				"/deleteRole",
				"/saveRole",
				"/popupAccount2Role",
				"/ajaxRoleQueryAccount",
				"/ajaxRoleQueryAccountSelected",
				"/popupRole2Function",
				"/ajaxRoleQueryFunction",
				"/ajaxRoleQueryFunctionSelected",
				"/ajaxRoleQueryItem"	// used by role2FunctionEdit
				})
	public RoleAction role() {
		logger.debug("call RoleAction");
		return new RoleAction("/role");
	}
}